package com.ssm.modules.service.impl;

import com.ssm.modules.dao.ILogDao;
import com.ssm.modules.entity.Log;
import com.ssm.modules.entity.User;
import com.ssm.modules.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("logService")
public class LogServiceImpl implements ILogService {

    @Autowired
    private ILogDao logDao;

    public Integer insert(Log log) {
        return logDao.insert(log);
    }

    public List<Log> findAll(int page, int pageSize) {
        if(page > 0) {
            page = (page - 1) * pageSize;
        }
        return logDao.findAll(page, pageSize);
    }

    public int findAllCount() {
        return logDao.findAllCount();
    }

    public List<Log> findByUserId(int userId, int page, int pageSize) {
        if(page > 0) {
            page = (page - 1) * pageSize;
        }
        return logDao.findByUserId(userId, page, pageSize);
    }

    public int findByUserIdCount(int userId) {
        return logDao.findByUserIdCount(userId);
    }

    public List<Integer> getUsersVisitCount(List<User> users) {
        return logDao.getUsersVisitCount(users);
    }
}
